// bookcapDlg.h : header file
//

#pragma once
#include "afxwin.h"

#include <sapi.h> 
#include <tessdll.h>

#define MAX_OCR_RESULT		32000

class CCrop;
class CTalkBar;

// CbookcapDlg dialog
class CbookcapDlg : public CDialog
{
// Construction
public:
	CbookcapDlg(CWnd* pParent = NULL);	// standard constructor
	~CbookcapDlg();
// Dialog Data
	enum { IDD = IDD_BOOKCAP_DIALOG };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON	m_hIcon;
	HANDLE	m_BackIcon;
	HCURSOR	m_LinkCursor;
	HFONT	m_hFont;
	HMENU	m_hMenu;
	CToolTipCtrl	m_Tooltip;
	int		m_underline;
	void	create_tray();

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg LRESULT hook_notify(WPARAM w,LPARAM l);
	afx_msg LRESULT tray_notify(WPARAM w,LPARAM l);
	DECLARE_MESSAGE_MAP()


public:
	CButton m_KeyShift;
	CButton m_KeyControl;
	CButton m_KeyAlt;
	CEdit m_Hotkey;
	CButton m_AutoStart;
	CButton m_AppendFile;
	CButton m_CopyClip;
	CButton m_Speak;
	CButton m_WatchClip;
	CStatic m_Link;

public:
	afx_msg void OnTimer(UINT_PTR nIDEvent);
	afx_msg void OnBnClickedHotKey();
	afx_msg void OnBnClickedAutostart();
	afx_msg void OnBnClickedAppend();
	afx_msg void OnBnClickedCopyclip();
	afx_msg void OnBnClickedSpeak();
	afx_msg void OnBnClickedWatchclip();
	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
	afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
	afx_msg void OnPaint();

	void	cropCompleted(int status);
	void	stopVoice();
	void	speakSelection();
	void	ShowTalkBar(int state);

protected:
	void	initHotkey();
	void	initAutostart();
	void	initClipSpeak();
	void	initCopyClip();
	void	initAppendFile();
	void	startCrop();
	void	cancelCrop();
	int 	GetTalkBar();
	void	processCrop();
	void	copyClipboard();
	void	checkClipboard();
	void	appendFile();
	void	firstRun();
	int		getProcessingLevel();
	int		isSpeaking();

	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
	virtual void OnCancel();

protected:
	CComPtr<ISpVoice>			m_cpVoice;
	int							m_textChange;
	TessDllAPI					m_TessApi;
	CCrop*						m_Crop;
	DWORD						m_clipnum;
	char						m_result[MAX_OCR_RESULT+1];
	TCHAR						m_wresult[MAX_OCR_RESULT+1];
	wchar_t						m_Filename[512];
	CTalkBar*					m_TalkBar;
public:
	virtual BOOL PreTranslateMessage(MSG* pMsg);
public:
	afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
};
